package com.example.myapplication.ViewModel

import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel

class TaskViewModel: ViewModel() {

    // 学习周期
    var taskDate by mutableStateOf("学习周期: 2022.01.01 - 2023.09.08")
        private set

    // 学年积分
    var pointOfYear by mutableStateOf(10000)
        private set

    // 学年总积分
    var totalPointOfYear = 13500

    // 学年积分进度
    // 计算方法: 最大角度 * 当前学年积分 / 学年总积分
    var pointOfYearPercent by mutableStateOf(0f)

    fun updatePointPercent() {
        pointOfYearPercent = 220f * pointOfYear / totalPointOfYear
    }

    // 一周积分
    val pointsOfWeek by mutableStateOf(listOf(0, 2, 3, 6, 3, 15, 8))

    // 折线图x轴文本
    val weeks by mutableStateOf(listOf("02.5", "02.6", "02.7", "02.8", "02.9", "02.10", "今日"))

    // 今日积分
    private var todayPoint = 8

    // 今日提醒文字
    var tips by mutableStateOf("今日获得0积分, 快去完成下面任务吧")
        private set

    fun updateTips() {
        tips = when (todayPoint) {
            0 -> {
                "今日获得0积分, 快去完成下面任务吧"
            }
            in 1..14 -> {
                "今日获得${todayPoint}积分, 快去完成下面任务吧"
            }
            else -> {
                "今日获得${todayPoint}积分, 已经完成任务"
            }
        }
    }
}